/**
 * @param {number[]} nums
 * @return {number}
 */
var removeDuplicates = function (nums) {
  let child = 0
  for (let father = 0; father < nums.length; father++) {
    if (nums[child] !== nums[father]) {
      child++
      nums[child] = nums[father]
    }
  }
  return child + 1
};


/**
 * @param {number[]} nums
 * @return {number}
 */
var removeDuplicates = function (nums) {
  for (let i = 0; i < nums.length; i++) {
    if (nums[i] === nums[i + 1]) {
      nums.splice(i, 1)
      i--
    }
  }
  return nums.length
};